package com.laibatour.generator.utils;

import org.apache.log4j.Logger;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by guan on 2016/2/23.
 */
public class PropertieUtils {
    static Logger log = Logger.getLogger(PropertieUtils.class);
    static Properties prop = new Properties();

    static {
        InputStream in = null;
        try {
            InputStream inputStream = PropertieUtils.class.getResourceAsStream("/generator.properties");
            //读取属性文件a.properties
            in = new BufferedInputStream(inputStream);
            prop.load(in);
        } catch (IOException e) {
            log.error("PropertieUtils",e);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    log.error("PropertieUtils",e);
                }
            }
        }
    }

    public static Properties getProp() {
        return prop;
    }

    public static String getProperty(String name) {
        return prop.getProperty(name);
    }


    public static String getProperty(String name, String defaultValue) {
        return prop.getProperty(name, defaultValue);
    }

}
